package HomeWork;

import java.util.Scanner;

//十进制转换为二进制
public class work07 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入一个十进制数:");
        int number=sc.nextInt();

        System.out.println("二进制数为:"+Integer.toBinaryString(number));

        transition(10);
    }

    private static void transition(int number) {
        String str="";
        while(number!=0){
            str=str+number%2;
            number=number/2;
        }
        StringBuffer str1=new StringBuffer(str);
        str1.reverse();
        System.out.println("二进制数为:"+str1);
    }
}
